import React, { Component } from 'react';
import '../css/register.css';
import $ from 'jquery';



class Register extends React.Component{
	constructor(props){
		super(props)
	
	}
	zhuce(){

		var values=$('.r-username').val();
				if(values==""){
					alert("请输入用户名")
					return
			
				}
				var _this=this;
				$.ajax({
					type:'get',
					url:'http://jx.xuzhixiang.top/ap/api/reg.php',
					data:{username:$('.r-username').val(),password:$('.r-password').val()},
					async:false,
					dataType:'json',
					success:function(data){
						console.log(data)
						if(data.code==1){
							
							alert("注册成功，跳转登录");
							window.location.href="#/login"
							
	
						}else{
							alert("注册失败，请重新注册");
							window.location.href="#/register"
						
	
						 }
						
					}
					
				})
	}
	fanhuia(){
		this.props.history.goBack();
	}

	render(){
		var _this=this;
		return(
			<div className='register'>
				<header className='register-header'>
					<span  onClick={this.fanhuia.bind(this)}>&lt;</span>
					<h1>注册</h1>
				</header>
				<section className='register-section'>
					<input type='text' placeholder='请输入手机号码' className="r-username"/>
					{/* <input type='text' placeholder='请输入验证码'/> */}
					<input type='text' placeholder='请设置6-12位字母数字组合密码' className="r-password"/>
					{/* <input type='text' placeholder='请再次输入密码'/> */}
					<input type='text' placeholder='请输入6位邀请码（非必填）'/>
					<input type='button' value='立即注册' className="rzhuce" onClick={this.zhuce.bind(this)} />
				</section>
			</div>
		)
	}
}

export default Register;